﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JetBrains.ReSharper.Psi.CSharp.Tree;
using Twins.Infrastructure;
using Twins.Interface;
using Twins.Interface.IHandler;

namespace Twins.Classes.Hanlder.HanlderStatement
{
    public class HanlderForIDoStatement : IHandler<IDoStatement>
    {
        public IEnumerable<ILineCode> DoFor(IDoStatement doStatement)
        {
            var hashLineCode = doStatement.DoKeyword.GetText();
            var receiveHashLineCodeFromProcesserCSharpExpression = IoC
                .Resolve<IReceiveHashLineCodeFromProcesserCSharpExpression>();
            receiveHashLineCodeFromProcesserCSharpExpression
                .ReceiveHashLineCode(doStatement.Condition, ref hashLineCode);
            var receiveHashLineCodeFromProcesserCSharpStatement = IoC
                .Resolve<IReceiveHashLineCodeFromProcesserCSharpStatement>();
            return receiveHashLineCodeFromProcesserCSharpStatement
                .ReceiveHashLineCode(doStatement, doStatement.Body, hashLineCode); 
        }

        public IEnumerable<ILineCode> DoFor(object obj)
        {
            return DoFor((IDoStatement)obj);
        }
    }
}
